<html>
<head><meta charset="utf-8"><title>macros 2.0 dogfooding · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html">macros 2.0 dogfooding</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="240095997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240095997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240095997">(May 24 2021 at 19:00)</a>:</h4>
<p>grep shows about 300 uses of <code>macro_rules!</code> in the compiler. Would people be receptive if I started to move those over to <code>macro</code>?</p>



<a name="240096874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240096874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240096874">(May 24 2021 at 19:06)</a>:</h4>
<p>I think macros 2.0 isn't near enough to stabilization even for internal use, but I could be wrong -- that is, my reading is that the current <code>macro</code> might get completely replaced.</p>



<a name="240096903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240096903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240096903">(May 24 2021 at 19:06)</a>:</h4>
<p>I don't think it's worth the migration(s) to change anything now</p>



<a name="240097875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240097875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240097875">(May 24 2021 at 19:14)</a>:</h4>
<p>It's harder to grep for but <code>macro</code> also gets used extensively; in particular the stdlib has begun stabilizing APIs that use it (<a href="https://doc.rust-lang.org/src/core/ptr/mod.rs.html#1538-1540"><code>std::ptr::addr_of</code></a>, <a href="https://doc.rust-lang.org/src/core/task/ready.rs.html#54-61"><code>std::task::ready</code></a>), and all the derive macros like <code>Clone</code> are using it (although they're builtins, so maybe that's cheating)</p>



<a name="240097960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240097960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240097960">(May 24 2021 at 19:15)</a>:</h4>
<p>sure, std lib has relatively fewer macros -- and making grepping harder IMO is a key reason to avoid it :)</p>



<a name="240098009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240098009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240098009">(May 24 2021 at 19:15)</a>:</h4>
<p>Macros can be hard to find the definition of as-is, grepping being harder doesn't help</p>



<a name="240098203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240098203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240098203">(May 24 2021 at 19:16)</a>:</h4>
<p>well it's harder to grep for all uses of "macro", but that's not something that anybody really needs to do regularly. in terms of finding the definition of any individual item it's just as easy to <code>grep "macro foo"</code> as it is to <code>grep "macro_rules\! foo"</code></p>



<a name="240098274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240098274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240098274">(May 24 2021 at 19:17)</a>:</h4>
<p>and since <code>macro</code> actually supports namespaces, it makes it easier to organize them properly :P</p>



<a name="240098447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240098447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240098447">(May 24 2021 at 19:18)</a>:</h4>
<p>and due to supporting namespacing it seems likely that std will be using them for all macros going forward, which is why I wanted to dogfood them some more</p>



<a name="240099142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240099142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240099142">(May 24 2021 at 19:24)</a>:</h4>
<p>Macros 2.0 don't yet have a hygiene opt-out, so you have to pass item names to them, which makes them less convenient than <code>macro_rules</code> in maybe ~50% (?) of cases.</p>



<a name="240099419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240099419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240099419">(May 24 2021 at 19:26)</a>:</h4>
<p>They also mark all private items they can assess as reachable from outside of the crate (if the macro is public), which also may require isolating them to a separate module, which again makes them less convenient in some cases.</p>



<a name="240099567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240099567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240099567">(May 24 2021 at 19:27)</a>:</h4>
<p>So, you can certainly try to replace <code>macro_rules</code> with <code>macro</code>s, but you should be ready for some rough edges.</p>



<a name="240099690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240099690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240099690">(May 24 2021 at 19:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> <a href="#narrow/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding/near/240099142">said</a>:</p>
<blockquote>
<p>Macros 2.0 don't yet have a hygiene opt-out, so you have to pass item names to them, which makes them less convenient than <code>macro_rules</code> in maybe ~50% (?) of cases.</p>
</blockquote>
<p>hm, isn't that what the <code>#[rustc_macro_transparency]</code> attribute is used for?</p>



<a name="240099705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240099705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240099705">(May 24 2021 at 19:28)</a>:</h4>
<p>That said, the use of <code>macro</code>s in the standard library resulted in eliminating a number of bugs of their implementation.</p>



<a name="240100085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240100085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240100085">(May 24 2021 at 19:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span> <a href="#narrow/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding/near/240099690">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> <a href="#narrow/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding/near/240099142">said</a>:</p>
<blockquote>
<p>Macros 2.0 don't yet have a hygiene opt-out, so you have to pass item names to them, which makes them less convenient than <code>macro_rules</code> in maybe ~50% (?) of cases.</p>
</blockquote>
<p>hm, isn't that what the <code>#[rustc_macro_transparency]</code> attribute is used for?</p>
</blockquote>
<p>Well yes, except that it was supposed to be a testing tool rather than something to be used "in production".</p>



<a name="240102856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240102856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240102856">(May 24 2021 at 19:52)</a>:</h4>
<blockquote>
<p>They also mark all private items they can assess as reachable from outside of the crate (if the macro is public), which also may require isolating them to a separate module, which again makes them less convenient in some cases.</p>
</blockquote>
<p>Last time I tried, I had to export items to make them accessible from an exported macros 2.0 macro.</p>



<a name="240103141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240103141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240103141">(May 24 2021 at 19:54)</a>:</h4>
<p>I am using only macros 2.0 in cg_clif. I really like the single match arm shorthand and the namespacing.</p>



<a name="240121644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240121644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240121644">(May 24 2021 at 22:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> <a href="#narrow/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding/near/240099567">said</a>:</p>
<blockquote>
<p>So, you can certainly try to replace <code>macro_rules</code> with <code>macro</code>s, but you should be ready for some rough edges.</p>
</blockquote>
<p>I'm happy to do the work of trying, as long as the patches are welcome :)</p>



<a name="240257697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240257697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240257697">(May 25 2021 at 22:21)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding/near/240102856">said</a>:</p>
<blockquote>
<blockquote>
<p>They also mark all private items they can assess as reachable from outside of the crate (if the macro is public), which also may require isolating them to a separate module, which again makes them less convenient in some cases.</p>
</blockquote>
<p>Last time I tried, I had to export items to make them accessible from an exported macros 2.0 macro.</p>
</blockquote>
<p>I can't tell if this is refuting or supporting the prior comment... though possibly because I don't know what the intended behavior is supposed to be. :) Do you mean that something like <code>struct Foo; pub macro bar() { Foo }</code> (escaping private item) required <code>pub struct Foo</code>, and that's a good thing? Or do you mean that something like <code>struct Foo; pub macro bar() { drop(Foo); }</code> (non-escaping private item) required <code>pub struct Foo</code>, and that's a bad thing? I don't see any issue on the tracker talking about problems with private items in macros.</p>



<a name="240281263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240281263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240281263">(May 26 2021 at 05:30)</a>:</h4>
<p>I am refuting the prior comment. The prior comment said that it would work. I said it didn't when I last tried. I am not saying whether it is a good or bad thing.</p>



<a name="240309792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240309792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240309792">(May 26 2021 at 11:31)</a>:</h4>
<p>It's supposed to work if you are not using something affected by <a href="https://github.com/rust-lang/rfcs/blob/master/text/2145-type-privacy.md">*type* privacy</a> (e.g. accessing private modules, imports, type aliases - ok, private types - not ok).</p>



<a name="240315188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240315188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240315188">(May 26 2021 at 12:23)</a>:</h4>
<p>Ah, I see.</p>



<a name="240350642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240350642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240350642">(May 26 2021 at 16:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> <a href="#narrow/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding/near/240309792">said</a>:</p>
<blockquote>
<p>It's supposed to work if you are not using something affected by <a href="https://github.com/rust-lang/rfcs/blob/master/text/2145-type-privacy.md">*type* privacy</a> (e.g. accessing private modules, imports, type aliases - ok, private types - not ok).</p>
</blockquote>
<p>Yes, I think I've already noticed this. rustc_arena defines three macros, one of which is used outside the crate and the other two are helpers that only get used inside the first macro. If I'm reading this correctly then I would expect that the two helper macros would not have to be public, but currently they must be public. Am I correct in my interpretation? (That said, all three macros are already marked as <code>#[macro_export]</code>under macros 1.0, so it's not making it any worse.)</p>



<a name="240380854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240380854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240380854">(May 26 2021 at 19:49)</a>:</h4>
<blockquote>
<p>If I'm reading this correctly then I would expect that the two helper macros would not have to be public, but currently they must be public.</p>
</blockquote>
<p>I've just checked, they are not required to be public.<br>
They only require <code>#[allow(unused_macros)]</code> because there's no way to know that tokens generated by the public macro refer to them.</p>



<a name="240381288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240381288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240381288">(May 26 2021 at 19:52)</a>:</h4>
<p>The alternative is to consider all private items potentially accessible to public macros to be used in <code>unused</code> lints.</p>



<a name="240381916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240381916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240381916">(May 26 2021 at 19:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123856">Vadim Petrochenkov</span> <a href="#narrow/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding/near/240380854">said</a>:</p>
<blockquote>
<blockquote>
<p>If I'm reading this correctly then I would expect that the two helper macros would not have to be public, but currently they must be public.</p>
</blockquote>
<p>I've just checked, they are not required to be public.<br>
They only require <code>#[allow(unused_macros)]</code> because there's no way to know that tokens generated by the public macro refer to them.</p>
</blockquote>
<p>I tried that earlier and got this:</p>
<div class="codehilite"><pre><span></span><code>error[E0603]: macro `arena_for_type` is private
   --&gt; /Users/bapple/Code/rust/compiler/rustc_arena/src/lib.rs:645:26
    |
645 |         $($name: $crate::arena_for_type!($a[$ty]),)*
    |                          ^^^^^^^^^^^^^^ private macro
    |
note: the macro `arena_for_type` is defined here
   --&gt; /Users/bapple/Code/rust/compiler/rustc_arena/src/lib.rs:614:1
    |
614 | macro arena_for_type {
    | ^^^^^^^^^^^^^^^^^^^^
</code></pre></div>



<a name="240381970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240381970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240381970">(May 26 2021 at 19:56)</a>:</h4>
<p>I really don't like this aspect of macros 2.0, maybe it would be better to require them to declare a list of the items they want to have made available to the expanded code?</p>



<a name="240382521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240382521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240382521">(May 26 2021 at 20:00)</a>:</h4>
<p>well the unused_macros lint thing isn't exclusive to macros 2.0, you get the same errors with macros 1.0</p>



<a name="240382733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240382733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240382733">(May 26 2021 at 20:01)</a>:</h4>
<p>like, with <code>local_inner_macros</code> or how?</p>



<a name="240383061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240383061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240383061">(May 26 2021 at 20:03)</a>:</h4>
<blockquote>
<p>I tried that earlier and got this:</p>
</blockquote>
<p>Ah, I see, this is due to <code>#[rustc_macro_transparency = "semitransparent"]</code>.<br>
Semitransparent macros do not use the macro 2.0 hygiene which is responsible for ability to access private items as well.</p>



<a name="240383262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240383262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240383262">(May 26 2021 at 20:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span> <a href="#narrow/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding/near/240382521">said</a>:</p>
<blockquote>
<p>well the unused_macros lint thing isn't exclusive to macros 2.0, you get the same errors with macros 1.0</p>
</blockquote>
<p>You cannot reference anything private from a macro 1.0, and if it's not private then it will be considered "used".</p>



<a name="240383366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/macros%202.0%20dogfooding/near/240383366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding.html#240383366">(May 26 2021 at 20:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211727">Jonas Schievink  [he/him]</span> <a href="#narrow/stream/131828-t-compiler/topic/macros.202.2E0.20dogfooding/near/240381970">said</a>:</p>
<blockquote>
<p>I really don't like this aspect of macros 2.0, maybe it would be better to require them to declare a list of the items they want to have made available to the expanded code?</p>
</blockquote>
<p>Maybe.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>